<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>首页</title>
  <style>
    *,
    *::after,
    *::before {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    :root {
      min-height: 100vh;
    }

    :root:focus-within {
      scroll-behavior: smooth;
    }

    body {
      min-height: inherit;
    }
  </style>
</head>

<body>
  <div></div>
</body>
<script>
  "use strict"; {
    let i = 0;

    let start = Date.now();
    let t = requestAnimationFrame(function fn() {
      let end = Date.now();
      if (end - start >= 1000) {
        i++;
        console.log(`每隔一秒输出 ${i}`);

        start = end;
      };
      if (i == 10) {
        cancelAnimationFrame(t);
        return;
      };
      t = requestAnimationFrame(fn);
    });
  };
</script>

</html>